public class Main {
    public static void main(String[] args) {

        try {
            if (args.length != 2) {
                throw new ArrayIndexOutOfBoundsException("数据个数不对");
                //这里的throw会使程序立即转移到对应的catch块中，如果没有就向上一层抛出
            }
            int n1 = Integer.parseInt(args[0]);
            int n2 = Integer.parseInt(args[1]);
            double res = cal(n1, n2);
            System.out.println("计算结果是" + res);
        }
         catch (ArrayIndexOutOfBoundsException e) {
                System.out.println(e.getMessage());
        }catch (NumberFormatException e) {
            System.out.println("参数格式不正确！");
        }
        catch (ArithmeticException e) {
            System.out.println("出现了除0异常！");
        }
    }
    //除法方法
    public static double cal(int a,int b){
        return a/b;
    }
}
